//============================================================================
// Name        : locnet.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
//============================================================================

#include <iostream>
#include <unistd.h>
#include "pool/Threadpool.h"
using namespace std;

void* th(void *p) {
//	cout << p << endl;
	cout << pthread_self() << endl;
	return 0;
}

int main() {
//	Thread thread(th, (void*) 1,);
//	AbstractThread *abt = &thread;
	Threadpool pool(4,NULL, th, (void*) 1);
	pool.setExpansion(4);
//	pool.expansioncap(10);
//	pool.setExpansioncapable(false);
	cout << pool.getUsedThreadNum() << endl;
	cout << pool.emptyThreadNum() << endl;
	cout << pool.allThreadNum() << endl;
//	sleep(1);
	pool.getThread((void*) 2);
	pool.getThread((void*) 3);
	pool.getThread((void*) 4);
	pool.getThread(NULL);
	pool.getThread((void*) 2);
	pool.getThread((void*) 3);
	pool.getThread((void*) 4);
	pool.getThread(NULL);
//	sleep(1);
	pool.getThread((void*) 4);
	pool.getThread((void*) 4);
	cout << pool.getUsedThreadNum() << endl;
	cout << pool.emptyThreadNum() << endl;
	cout << pool.allThreadNum() << endl;
	sleep(1);
	cout << pool.getUsedThreadNum() << endl;
	cout << pool.emptyThreadNum() << endl;
	cout << pool.allThreadNum() << endl;
	sleep(40);
	cout << pool.getUsedThreadNum() << endl;
	cout << pool.emptyThreadNum() << endl;
	cout << pool.allThreadNum() << endl;
	while (true)
		;
	return 0;
}
